#include <iostream>

using namespace std;

typedef long long LL;

void solve()
{
    int n; cin >> n;
    string s; cin >> s;
    LL ret = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'e')
        {
            for(int j = i + 1; j < n; j++)
            {
                if(s[j] == 'f') ret += j - i;
            }
        }
    }
    cout << ret << endl;
}

int main()
{
    int T = 1; 
    while(T--) solve();
    return 0;
}